Add parameter decoding CLI tool to F` GDS#285
Conversation
Implement a new CLI tool to decode binary parameter database (.dat) files into human-readable formats (JSON, text, CSV). This provides the inverse operation of fprime-prm-write, enabling inspection and debugging of parameter files. Features: - Decode .dat files to JSON format (round-trip compatible with fprime-prm-write) - Human-readable text output with type and ID information - CSV output for spreadsheet compatibility - Comprehensive error handling for invalid or corrupted files - Full test coverage with 9 new tests Changes: - Add decode_dat_to_params() and formatter functions to params.py - Add main_decode() CLI entry point - Register fprime-prm-decode command in pyproject.toml - Add comprehensive test suite in test_prm_decode.py All 284 fprime-gds tests pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… are injestable by fprime-prm-write
thomas-bc
left a comment
There was a problem hiding this comment.
Leveraging the global config singleton would help a lot with making these more portable. I wonder if you could prompt your AI to do that - it should be able to handle it fairly easily since other places in the repo are doing the same thing quite a lot.
As long as UTs pass, we should be fine.
But I'm also happy to take this in as is since the encode() variant doesn't currently do it.
| offset += 1 | ||
|
|
||
| # Read record size (4 bytes, big endian) | ||
| if offset + 4 > len(dat_bytes): |
There was a problem hiding this comment.
I'm seeing hardcoded widths and such. You should instead be using the loaded dictionary types. See my other comment on how to do that. Once you do have it, you should be able to do something like
from fprime_gds.common.utils.config_manager import ConfigManager
record_id_size = ConfigManager().get_type("FwDpIdType").getSize()| ) | ||
| arg_parser.add_argument( | ||
| "--dictionary", | ||
| "-d", |
There was a problem hiding this comment.
With that argument, you can leverage the pre-existing Dictionaries class which can load all the dictionary types into a global config singleton, which will help processing without hardcoding type widths and such.
See
fprime-gds/src/fprime_gds/executables/data_products.py
Lines 26 to 28 in 620cc30
thomas-bc
left a comment
There was a problem hiding this comment.
Looks good - let's merge this as is and I will capture a follow-up ticket to consolidate both scripts with Dictionary loading etc.
|
Follow up ticket: nasa/fprime#4792 |
Change Description
Adds
fprime-prm-decodeCLI tool to decode binary parameter database (.dat) files into human-readable formats (JSON, text, CSV). This provides the inverse operation offprime-prm-write.Changes:
fprime-prm-decodecommand-line toolfprime-prm-writeinput formatRationale
fprime-prm-writecan encode parameter JSON to binary .dat files, but there's no way to decode them back. This makes it difficult to:This tool completes the parameter workflow by enabling developers to inspect, verify, and debug parameter databases.
Testing/Review Recommendations
Unit Tests (14 tests, all passing):
Review Recommendation:
src/fprime_gds/common/tools/params.py: Review decode functions andmain_decode()entry pointpyproject.toml: Reviewfprime-prm-decodeCLI command registrationtest/fprime_gds/common/tools/test_prm_decode.py: Review 14 new unit testsFuture Work
None planned.
AI Usage (see policy)
Claude (Sonnet 4.5) was used extensively in this contribution for:
All AI-generated code was reviewed, tested, and verified by myself. Round trip conversion of a parameter database was done manually using a flight like database.